// pages/caicaicai/nidex.js
let userNumber;
let computerNumber;

Page({
  data:{
    focus :true,
    list :[]
  },
  onLoad(options){
    computerNumber = parseInt(Math.random()*100)
    console.log('计算机想的数据：',computerNumber)
  },
  guessData(e){
    console.log(e.detail.value)
    userNumber=parseInt(e.detail.value)
  },
  caicaicai(e){
    let result=null;
    let list=this.data.list
    list.push(userNumber)
    if(list.length>8) list.shift()
    if(userNumber>computerNumber){
      result='你猜大了~'
    }else if(userNumber<computerNumber){
      result='你猜小了~'
    }else{
      result='恭喜你终于猜对了~'
    }
    this.setData({result:result,list,userData:null,focus:true})
  }
})